package com.ysh.ssm.mapper;

import com.ysh.ssm.pojo.TbUser;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 袁胜虎 on 2022/8/31 21:43
 */
public interface UserMapper {
    @Select("select * from tb_user where id = #{id}")
    TbUser findById(Long id);

    @Insert("insert  into tb_user(username,password,email,gender) values (#{username},#{password},#{email},#{gender})")
    void addUser(TbUser tbUser);

    @Select("select * from tb_user")
    List<TbUser> findUsers();

    @Select("select * from tb_user where username = #{username} and password = #{password}")
    TbUser findUsernameAndPassword(@Param("username") String username,@Param("password") String password);

    @Delete("delete from tb_user where id = #{id}")
    void deleteById(Long id);

    @Update("update tb_user set username=#{username},password=#{password},email = #{email},gender=#{gender} where id = #{id}")
    void updateUser(@Param("username")String username,@Param("password")String password,@Param("email")String email,@Param("gender")String gender,@Param("id") Long id);

}
